<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="<c:url value='/js/jquery-1.11.1.min.js'/>"></script>
<script src="js/bootstrap.min.js"></script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>成功页面</title>
<link rel="stylesheet" type="text/css" href="WebContent/css/main.css">
<script language="javascript">
	var currentDate = new Date(
<%=new java.util.Date().getTime()%>
	);
	function run() {
		currentDate.setSeconds(currentDate.getSeconds() + 1);
		document.getElementById("currentTime").innerHTML = currentDate
				.toLocaleString();
	}

	window.setInterval("run();", 1000);

	function changePage(method) {

		var pageNo = document.forms[0].pageNo.value;
		var total = document.forms[0].total.value;
		if (method == "next") {
			if (parseInt(pageNo) >= parseInt(total)) {
				alert("当前已经是最后一页！");
				return false;
			} else {
				document.forms[0].pageNo.value = parseInt(pageNo) + 1;
			}
		}
		if (method == "previous") {
			if (parseInt(pageNo) <= 1) {
				alert("当前已经是第一页");
				return false;
			} else {
				document.forms[0].pageNo.value = parseInt(pageNo) - 1;
			}
		}
		if (method == "first") {
			document.forms[0].pageNo.value = 1;
		}
		if (method == "end") {
			document.forms[0].pageNo.value = total;
		}

		document.forms[0].submit();
	}

</script>
</head>
<body>
	<div style="float:right;">
	<div class="btn-group">
   <button type="button" class="btn btn-primary dropdown-toggle" 
      data-toggle="dropdown">
欢迎您:${userInfologin.userName }<span class="caret"></span>
   </button>
   <ul class="dropdown-menu" role="menu">
      <li><a href="<c:url value='/UserInfoAction?oper=personaledit&id=${userInfologin.id}'/>">个人资料修改</a></li>
      <li><a href="<c:url value='/UserInfoAction?oper=editPsw'/>">密码修改</a></li>
   </ul>
</div>
	<br/>
	<span  style="float:right;">${msg }</span>
	</div>
	

<div style="width:800px;height:50px;">
	
	<ul class="nav nav-pills">
   <li class="active"><a href="<c:url value='/ClothingAction?oper=defaultlist'/>">首页</a></li>
   <li><a href="<c:url value='/BuycarAction?oper=list'/>">我的购物车</a></li>
   <li><a href="<c:url value='UserInfoAction?oper=myOrder'/>">我的订单</a></li>
   <li><a href="<c:url value='/UserInfoAction?oper=loginout'/>">退出登录</a></li>
</ul>
</div>
<div class="clearfix"></div>
	 <form action="<c:url value='/ClothingAction?oper=defaultlist'/>" method="post" class="bs-example bs-example-form" role="form">
   <input type="hidden" name="pageNo" value="${pageNo}"> 
		<input type="hidden" name="total" value="${total}">
            <div style="width:100%;height:50px;">
            <div style="width:550px;float:right;">
         <div class="col-lg-6">
            <div class="input-group">
               <input type="text" class="form-control"  name="name" value="${name }" placeholder="搜索想要的衣服吧！">
               <span class="input-group-btn">
                  <button class="btn btn-default" type="submit" onclick="changePage('first')">
                    <b class="glyphicon glyphicon-search"></b>
                  </button>
               </span>
            </div><!-- /input-group -->
         </div><!-- /.col-lg-6 -->
         </div>
         </div>
   </form>

<div style="margin:0 auto;width:800px;">
	
		<c:forEach items="${clothinglist }" var="clothing">
		<div style="float:left;margin-right:100px;text-align: center;">
	<c:choose>
		<c:when test="${empty clothing.picture }">
			
			<a href="<c:url value='/ClothingAction?oper=get&id=${clothing.id }'/>"><img src="images/1.jpg" width="270" height="420" style="float:left;"></a>
			<br/>
		</c:when>
		<c:otherwise>
			<a href="<c:url value='/ClothingAction?oper=get&id=${clothing.id }'/>"><img src="<c:url value="/upload/${clothing.picture}"/>"
				width="270" height="420" style="float:left;"></a>
				<br/>
		</c:otherwise>
	</c:choose>
	<div class="clearfix"></div>
	
				${clothing.name }
				<br/>
				价格：${clothing.price}￥
				<br/>
				售价：${clothing.saleprice}￥
				<br/>
				${clothing.summary}
				<br/>
				<a href="<c:url value='/BuycarAction?oper=save&id=${clothing.id }&pageNo=${pageNo}'/>">加入购物车<b class="glyphicon glyphicon-shopping-cart"></b></a>
	</div>
		
		</c:forEach>
		<div class="clearfix"></div>
	<table style="margin:0 auto;">
		<tr>
		
			<td colspan="3">查询到：${count}条记录 <a href="#"
				onclick="changePage('first')">首页</a> <a href="#"
				onclick="changePage('previous')">上一页</a> <a href="#"
				onclick="changePage('next')">下一页</a> 第${ pageNo}页/共${total}页 <a
				href="#" onclick="changePage('end')">尾页</a>
			</td>
		</tr>
	</table>
</div>
	<div id="currentTime"></div>
</body>
</html>